package presentation;

import java.awt.Adjustable;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.jms.JMSException;
import javax.swing.*;

import commucation.MessagesReceiver;

import traitement.MessageTableModel;
import traitement.OrderTableModel;

public class ControlCenterFrame extends JFrame{
	
	private static final long serialVersionUID = 862960466847268055L;
	private MessageTableModel messageModele = new MessageTableModel();;
    private JTable messagesTable;
    private OrderTableModel orderModele = new OrderTableModel();
    private JTable ordersTable;
    private MessagesReceiver receiver = new MessagesReceiver();
    JScrollBar scrollBarVertical = new JScrollBar();
    JScrollBar scrollbarHorizontal = new JScrollBar(Adjustable.HORIZONTAL);
    JScrollBar scrollBarVertical2 = new JScrollBar();
    JScrollBar scrollbarHorizontal2 = new JScrollBar(Adjustable.HORIZONTAL);

	ControlCenterFrame() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setSize(600, 400);
		this.setTitle("Mock Centre de Controle");
		
		scrollBarVertical.setPreferredSize(new Dimension(20, 200));
	    scrollbarHorizontal.setPreferredSize(new Dimension(200, 20));
	    
		this.setLayout(new GridLayout(0,2));
		
		messagesTable = new JTable(receiver.getListener().getMessages());
		ordersTable = new JTable(orderModele);
		getContentPane().add(new JScrollPane(messagesTable));
		getContentPane().add(new JScrollPane(ordersTable));
		 
		 messagesTable.add(scrollBarVertical);
		 messagesTable.add(scrollbarHorizontal);
		 ordersTable.add(scrollBarVertical2);
		 ordersTable.add(scrollbarHorizontal2);
		
		setVisible(true);
		try {
			receiver.listenOn("MessagesTopics");
		} catch (JMSException e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String args[]) {
		new ControlCenterFrame();
		
		
	}
}
